package cn.com.ht.security.controller;

import cn.com.ht.security.model.Person;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController(value = "/")
@PreAuthorize("hasRole('ROLE_USER')")
public class PersonService {

    private static final List<Person> persons;

    static {
        persons = new ArrayList<Person>(){
            {
                add(new Person("zhangsan","zhangsan@qq.com"));
                add(new Person("lisi","lisi@qq.com"));
            }
        };

    }

    @GetMapping(value = "/getUsers")
    public static List<Person> getPersons() {
        return persons;
    }
}
